function string.split(str, delimiter)
        if str==nil or str=='' or delimiter==nil then
                return nil
        end

    local result = {}
    for match in (str..delimiter):gmatch("(.-)"..delimiter) do
        table.insert(result, match)
    end
    return result
end

local key = KEYS[1]

local result = {}

for i,v in ipairs(ARGV) do
    
    if (v ~= nil) then
        local index = redis.call("zrank", key, v)
        if (index) then -- 指定业务端的指定类型
            table.insert(result, 1)
        else
           local array = string.split(v, ":")
           -- 指定业务端的所有业务类型
           index = redis.call("zrank", key, array[1].."::"..array[3])
           if (index) then
               table.insert(result, 1) 
           else
               -- 指定业务类型的所有业务端
               index = redis.call("zrank", key, ":"..array[2]..":"..array[3])
               if (index) then
                   table.insert(result, 1)
               else
                   -- 所有业务端的所有类型
                   index = redis.call("zrank", key, "::"..array[3])
                   if (index) then
                       table.insert(result, 1)
                   else
                       table.insert(result, 0)
                   end
               end
           end
        end
    else
        table.insert(result, 0)
    end
end

return result
